import 'package:flutter/material.dart';
import 'package:material_dialogs/dialogs.dart';
import 'package:tracker/theme/app_theme.dart';

/// 秒定模式弹窗
class InstantModeDialog {
  final Function? onConfirm;
  late StateSetter _newSetState;

  InstantModeDialog({this.onConfirm});

  void show(BuildContext context) {
    Dialogs.bottomMaterialDialog(
      context: context,
      // title: 'VIP秒定模式',
      // titleStyle: TextStyle(
      //   fontSize: 18,
      //   color: AppTheme.themeConfig.primaryColor,
      //   fontWeight: FontWeight.bold,
      // ),
      // msg: '设备每隔10秒上报一次定位信息，启动高频率数据上传，您在APP回放轨迹时，可以看到的轨迹线段更完整，可查询更多更全的轨迹数据。',
      customView: StatefulBuilder(builder: (newContext, newSetState) {
        _newSetState = newSetState;
        return Container(
          padding: const EdgeInsets.only(left: 20, right: 20, top: 20),
          width: double.infinity,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                'VIP秒定模式',
                style: TextStyle(
                  fontSize: 18,
                  color: AppTheme.themeConfig.primaryColor,
                  fontWeight: FontWeight.bold,
                ),
              ),
              const SizedBox(height: 20),
              Text(
                '设备每隔10秒上报一次定位信息，启动高频率数据上传，您在APP回放轨迹时，可以看到的轨迹线段更完整，可查询更多更全的轨迹数据。',
                style: TextStyle(fontSize: 16, color: AppTheme.themeConfig.primaryTextColor),
              ),
            ],
          ),
        );
      }),
      actions: [
        TextButton(
          onPressed: () => Navigator.of(context).pop(),
          child: const Text(
            '取消',
            style: TextStyle(color: Colors.grey),
          ),
        ),
        TextButton(
          onPressed: () {
            Navigator.of(context).pop();
            if (onConfirm != null) {
              onConfirm!();
            }
          },
          child: Text(
            '立即开启',
            style: TextStyle(color: AppTheme.themeConfig.primaryColor),
          ),
        ),
      ],
    );
  }
}
